package com.wuzhun.wxmp.controller;

import com.wuzhun.wxmp.config.ConfigMap;
import com.wuzhun.wxmp.util.DateTimeUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;

/**
 * base控制器
 *
 * @author : renbaolin
 * @date : 2022/12/27 9:54 下午
 */
@Controller
public class BaseController {

    @Resource
    private ConfigMap configMap;

    /**
     * 公共模板方法
     *
     * @param modelAndView
     * @param template
     * @return
     */
    public ModelAndView commonView(ModelAndView modelAndView, String template) {
        modelAndView.addObject("year", DateTimeUtil.getCurrentYear());
        modelAndView.addObject("configs", configMap.getConfigs());
        modelAndView.setViewName(template);
        return modelAndView;
    }
}
